import request from '@/utils/request'

// 获取员工列表
export const getEmpList = (params) => {
  return request.get('/sys/user', { params })
}

/**
 * 导出员工的excel
 * **/
export const exportEmployee = () => {
  return request.get('/sys/user/export', {
    // 改变接收数据的类型
    responseType: 'blob' // 使用blob接收二进制文件流
  })
}

// 导入模板
export const getExportTemplate = () => {
  return request.get('/sys/user/import/template', {
    // 改变接收数据的类型
    responseType: 'blob' // 使用blob接收二进制文件流
  })
}

// 上传接口
export const uploadExcel = (data) => {
  return request.post('/sys/user/import', data)
}

// 删除员工列表
export const delUser = (id) => {
  return request.delete(`/sys/user/${id}`)
}

// 新增员工
export const addEmployee = (data) => {
  return request.post('/sys/user', data)
}

// 员工详情
export const getEmployeeDetail = (id) => {
  return request.get(`/sys/user/${id}`)
}

// 编辑员工
export const updateEmployee = (data) => {
  return request.put(`/sys/user/${data.id}`, data)
}

export const getEnableRoleList = () => {
  return request.get('/sys/role/list/enabled')
}

export const assignRole = (data) => {
  return request.put('/sys/user/assignRoles', data)
}
